#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<signal.h>
struct sigaction act,oact;
void handler(int signo)
{
  printf("get a signal:%d\n",signo);
  sigaction(SIGINT,&oact,NULL);//恢复行为
}

int main()
{
  memset(&act,0,sizeof(act));
  memset(&oact,0,sizeof(oact));
  act.sa_handler=handler;
  act.sa_flags=0;
  sigemptyset(&act.sa_mask);
  sigaction(SIGINT,&act,&oact);//自定义捕获行为
  while(1)
  {
    printf("hello world\n");
    sleep(1);
  }
  return 0;
}
